package org.example.registry;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Registry {
    private static final Map<String, Class<?>> map = new ConcurrentHashMap<>();

    public static void register(String name, Class<?> clazz) {
        map.put(name, clazz);
        getAllServices();
    }

    public static Class<?> get(String name) {
        return map.get(name);
    }

    public static void unregister(String name) {
        map.remove(name);
    }

    public static void getAllServices() {
        System.out.println("All Services in Registry:");
        for(String key : map.keySet()) {
            System.out.println(key + " : " + map.get(key));
        }
        System.out.println("End of Services in Registry.");
    }
}
